import request from '@/utils/request'

/**
 * 根据spuId获取图片列表
 * @param {*} spuId
 * @returns
 */
export const reqSpuImageList = (spuId) => {
  return request({
    url: `/admin/product/spuImageList/${spuId}`,
    method: 'get'
  })
}

/**
 * 根据spuId获取销售属性列表
 * @param {*} spuId
 * @returns
 */
export const reqSpuSaleAttrList = (spuId) => {
  return request({
    url: `/admin/product/spuSaleAttrList/${spuId}`,
    method: 'get'
  })
}

/**
 * 根据三级分类的三个id获取平台属性数据
 * @param {*} category1Id:一级分类id
 * @param {*} category2Id:二级分类id
 * @param {*} category3Id:三级分类id
 * @returns
 */
export const reqAttrInfoList = (category1Id, category2Id, category3Id) => {
  return request({
    url: `/admin/product/attrInfoList/${category1Id}/${category2Id}/${category3Id}`,
    method: 'get'
  })
}

/**
 * 添加sku
 * @param {*} skuInfo
 * @returns
 */
export const reqAddSku = (skuInfo) => {
  return request({
    url: '/admin/product/saveSkuInfo',
    method: 'post'
  })
}

/**
 * 获取sku列表
 * @param {*} page:当前页
 * @param {*} limit:每页数量
 * @returns
 */
export const reqSkuList = (page, limit) => {
  return request({
    url: `/admin/product/list/${page}/${limit}`,
    method: 'get'
  })
}

/**
 * 上架
 * @param {*} skuId
 * @returns
 */
export const reqOnSale = (skuId) => {
  return request({
    url: `/admin/product/onSale/${skuId}`,
    method: 'get'
  })
}

/**
 * 下架
 * @param {*} skuId
 * @returns
 */
export const reqCancelSale = (skuId) => {
  return request({
    url: `/admin/product/cancelSale/${skuId}`,
    method: 'get'
  })
}

/**
 * 根据skuId获取sku信息
 * @param {*} skuId
 * @returns
 */
export const reqSkuById = (skuId) => {
  return request({
    url: `/admin/product/getSkuById/${skuId}`,
    method: 'get'
  })
}
